package com.eight.cloud.core.global.exception;

import com.eight.cloud.core.global.result.ResultCode;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.eight.cloud.core.global.result.IResultCode;

/**
 * 参数异常
 *
 * @ClassName: ParameterException
 * @Author: TXC
 * @Date: 2025-04-28 10:23
 **/
@EqualsAndHashCode(callSuper = true)
@Data
public class ParameterException extends RuntimeException{
    protected Integer code;
    protected String message;

    public ParameterException(IResultCode resultCode, Throwable e) {
        super(resultCode.getMessage(), e);
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
    }

    public ParameterException(IResultCode resultCode) {
        this(resultCode, null);
    }

    public ParameterException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public ParameterException(String message) {
        super(message);
        this.code = ResultCode.ERROR.getCode();
        this.message = message;
    }
}
